package com.fengqianrun.java.controller;

import cn.hutool.jwt.JWT;
import com.aizuda.easy.security.code.BasicCode;
import com.aizuda.easy.security.domain.Rep;
import com.aizuda.easy.security.domain.Req;
import com.aizuda.easy.security.exp.impl.BasicException;

import com.aizuda.easy.security.server.EasySecurityServer;
import com.aizuda.easy.security.util.LocalUtil;
import com.fengqianrun.java.domian.UserDTO;
import com.fengqianrun.java.domian.UserVO;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.List;

@RestController
@RequestMapping("/goods")
public class GoodsController  {

    @GetMapping("/list")
    public Rep<List<String>> list(){
        return Rep.ok(Arrays.asList("好男人就用..","爱他用他..","女生都喜欢..","30cm不是梦.."));
    }

    @PostMapping("/info")
    public Rep<String> info(@RequestBody Req<String, UserVO> req){
        String id = req.getData();
        // 缓存查询详情
        String info = "爱他用它 30cm 不是梦，喜欢就来购买................................";
        return Rep.ok(info);
    }

    @PostMapping("/buy")
    public Rep<String> buy(@RequestBody Req<Object, UserVO> req){
        String str = req.getData().toString();
        // 获取操作用户方式一
        UserVO userDto = req.getUser();
        // 获取操作用户方式二
        Object user = LocalUtil.getLocalEntity().getUser();
        System.out.println(user);
        return Rep.ok(userDto.getName());
    }

}
